package factory;

import constants.Constants;
import model.channel.Channel;
import model.channel.ChannelImpl;
import ihm.DisplayerPanel;
import ihm.DisplayerPanelImpl;
import model.observer.Displayer;
import model.observer.SensorObserver;
import model.subject.Sensor;
import model.subject.SensorImpl;
import model.algorithmes.AtomicSpreadingImpl;
import model.algorithmes.EpochSpreadingImpl;
import model.algorithmes.SequentialSpreadingImpl;
import model.algorithmes.SpreadingAlgorithme;

/**
 * Implémentation de l'interface CentralFactory.
 */
public class CentralFactoryImpl implements CentralFactory {

	@Override
	public DisplayerPanel createDisplayerPanel() {
		return new DisplayerPanelImpl();
	}

	@Override
	public Sensor createSensor() {
		return new SensorImpl();
	}

	@Override
	public SensorObserver createSensorObserver() {
		return new Displayer();
	}

	@Override
	public SpreadingAlgorithme createSpreadingAlgorithme(int strategyNumber) {
		switch(strategyNumber) {
		case Constants.ATOMIC_STRATEGY : return new AtomicSpreadingImpl();
		case Constants.SEQUENTIAL_STRATEGY : return new SequentialSpreadingImpl();
		case Constants.EPOCH_STRATEGY : return new EpochSpreadingImpl();
		default : System.out.println("Numéro de stratégie incorrect."); return null; 
		}
	}

	@Override
	public Channel createChannel() {
		return new ChannelImpl();
	}

}
